package quick.common;

import android.app.Application;

public class AppContext extends Application {

    private static AppContext app;

    public static String USERINFO_TOKEN= "UserInfo_Token";
    public static String Login_Token_Key = "Login_Token";
	
	private String username;
	private String token;
	
	public String getUserName()
	{
		return this.username;
	}
	
	public String getToken()
	{
		return this.token;
	}
	
	public void setUserInfo(String username,String token)
	{
		this.username = username;
		this.token = token;
		
		SharedPreferences.getInstance().putString(USERINFO_TOKEN, token);
	}
	
	public void clearUserInfo()
	{
		this.username = "";
		this.token = "";
		
		SharedPreferences.getInstance().putString(USERINFO_TOKEN, "");
	}

    public AppContext() {
        app = this;
    }

    public static synchronized AppContext getInstance() {
        if (app == null) {
            app = new AppContext();
        }
        return app;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        registerUncaughtExceptionHandler();
        // 在使用 SDK 各组间之前初始化 context 信息，传入 ApplicationContext
//        SDKInitializer.initialize(this);
    }

    // 注册App异常崩溃处理器
    private void registerUncaughtExceptionHandler() {
        Thread.setDefaultUncaughtExceptionHandler(AppException.getAppExceptionHandler());
    }

}